<?php

// require_once 'Zend/Gdata/Extension.php';
require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rats_Extension_TranscParams extends Raws_Extension_Params
{

    // protected $_rootNamespace = 'raws';
    // protected $_rootElement = 'params';
 
    protected $_filename = null;
    protected $_updated = null;

    public function __construct($filename = null, $updated = null) 
    {
        // foreach (Rats::$namespaces as $nsPrefix => $nsUri) {
        //     $this->registerNamespace($nsPrefix, $nsUri);
        // }
        parent::__construct();
        $this->_filename = $filename;
        $this->_updated = $updated;
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        if ($this->_filename !== null) {
            $element->appendChild($this->_filename->getDOM($element->ownerDocument));
        }
        if ($this->_updated !== null) {
            $element->appendChild($this->_updated->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'filename'; 
                $filename = new Rats_Extension_Filename();
                $filename->transferFromDOM($child);
                $this->_filename = $filename;
                break;
            case $this->lookupNamespace('raws') . ':' . 'updated'; 
                $updated = new Rats_Extension_Updated();
                $updated->transferFromDOM($child);
                $this->_updated = $updated;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }

    public function getFilename()
    {
        return $this->_filename;
    }

    public function setFilename($value)
    {
        $this->_filename = $value;
        return $this;
    }

    public function getUpdated()
    {
        return $this->_updated;
    }

    public function setUpdated($value)
    {
        $this->_updated = $value;
        return $this;
    }

}
